//
//  NSData+CLTimestamp.m
//  CLExtension
//
//  Created by CharlieLiao on 2017/8/4.
//  Copyright © 2017年 Charlie. All rights reserved.
//

#import "CLTimestamp.h"
//#import "CLFormatString.h"

@implementation NSDate (CLTimestamp)

///// 时间戳根据format转时间string
//+ (NSString *)dateStringWithTimestamp:(NSString *)timestamp format:(NSString *)format
//{
//    NSDate *date = [NSDate dateWithTimestamp:timestamp];
//    return [date toString:format];
//}

- (NSString*)timestamp
{
    NSTimeInterval timeInterval = [self timeIntervalSince1970];
    return [NSString stringWithFormat:@"%.0f",timeInterval*1000];
}

+ (NSDate*)dateWithTimestamp:(NSString*)timestamp
{
    NSTimeInterval timeInterval = [timestamp doubleValue]/1000;
    return [NSDate dateWithTimeIntervalSince1970:timeInterval];
}

+ (NSString*)nowTimestamp
{
    return [[NSDate date] timestamp];
}

//+ (NSString*)timestampForMonthStart
//{
//    NSTimeInterval timeInterval = [[[NSDate date] yearStartDate] timeIntervalSince1970];
//    return [NSString stringWithFormat:@"%.0f",timeInterval*1000];
//}
//+ (NSString*)timestampforNowStart{
//    NSTimeInterval nowinterval = [[self todayStartDate] timeIntervalSince1970];
//    return [NSString stringWithFormat:@"%.0f",nowinterval*1000];
//}
//+ (NSString*)timestampForWeekStart
//{
//    NSTimeInterval timeInteval = [[[NSDate date] monthStartDate]timeIntervalSince1970];
//    return [NSString stringWithFormat:@"%.0f",timeInteval*1000];
//}
//
//+ (NSString*)timestampForTodayStart
//{
//    NSTimeInterval timeInteval = [[[NSDate date] weekStartDate] timeIntervalSince1970];
//    return [NSString stringWithFormat:@"%.0f",timeInteval*1000];
//}

@end
